import {defineStore} from 'pinia'
import {ref} from 'vue'
export const useMemberStore = defineStore(
	'member',
	()=>{
		const profile = ref({
			token:undefined,
			userInfo:{
				headimgurl:undefined,
				nickname:undefined
			}
		})		
		const setProfile = (val)=>{
			profile.value.userInfo = val
		}
		const setToken = (val)=>{
			profile.value.token = val
		}
		const clearProfile = ()=>{
			profile.value = undefined
		}
		return{
			profile,
			setProfile,
			clearProfile,
			setToken
		}
	},
	{
		persist:{
			// persist: true,
			storage:{
				setItem(key,value){
					uni.setStorageSync(key,value)
				},
				getItem(key){
					return uni.getStorageSync(key)
				},	
			}
		}
	}
)